package com.example.park.weixiu

import android.widget.CheckBox
import android.widget.TextView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.example.lib_base.entity.WeiXiuEntityItem
import com.example.park.R

class WeiXiuAdapter:BaseQuickAdapter<WeiXiuEntityItem,BaseViewHolder>(R.layout.item_weixiu) {

    override fun convert(helper: BaseViewHolder, item: WeiXiuEntityItem) {
        //helper.getView<CheckBox>(R.id.cb).isChecked=item.isCheck
        helper.getView<CheckBox>(R.id.cb).isChecked=item.isCheck
        helper.setText(R.id.wx_gdh,"工单号：${item.orderNumber}")
        helper.setText(R.id.wx_time,"报修时间：${item.repairTime}")
        helper.setText(R.id.wx_ren,"报修人：${item.repairName}")
        val contactMethod = item.contactMethod
//        val start = contactMethod.substring(0, 3)
//        val next = contactMethod.substring(7,11)
//        helper.setText(R.id.wx_phone,"联系电话：${"$start****$next"}")
        helper.setText(R.id.wx_wz,"位置：${item.repairLocation}")
        helper.setText(R.id.wx_gzms,item.faultDescription)
        helper.setText(R.id.wx_type,item.processingStatus)
        val processingStatus = item.processingStatus
        if (processingStatus=="已完成"){
            helper.getView<TextView>(R.id.wx_type).setBackgroundResource(R.drawable.shape_status)
        }else if (processingStatus=="处理中"){
            helper.getView<TextView>(R.id.wx_type).setBackgroundResource(R.drawable.shape_solid_blue)
        }else{
            helper.getView<TextView>(R.id.wx_type).setBackgroundResource(R.drawable.shape_solid_lightgray)
        }
    }
}